package main

//func maxRepeating(sequence string, word string) (ans int) {
//	for i := 0; i < len(sequence); i++ {
//		if sequence[i] == word[0] {
//			j, count := i, 0
//			for j+len(word) <= len(sequence) && sequence[j:j+len(word)] == word {
//				count++
//				j += len(word)
//			}
//			if ans < count {
//				ans = count
//			}
//		}
//	}
//	return
//}

func lengthOfLongestSubstring(s string) int {
	var (
		ans int
		m   = map[byte]struct{}{}
		l   = 0
	)

	for r := 0; r < len(s); {
		if _, ok := m[s[r]]; !ok {
			m[s[r]] = struct{}{}
			r++
			if len(m) > ans {
				ans = len(m)
			}
		} else {
			delete(m, s[l])
			l++
		}
	}
	return ans
}
